<template>
    <div class="divBox">
        <el-card class="box-card">
            <el-form :model="form" label-width="120px">
                <el-form-item label="创建名片">
                    <el-radio-group v-model="form.creattCard">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="切换职位">
                    <el-radio-group v-model="form.switchPosition">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="授权开关">
                    <el-radio-group v-model="form.authSwitch">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="强制授权">
                    <el-radio-group v-model="form.forceAuth">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="替换头像">
                    <el-radio-group v-model="form.replaceAvater">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="名片海报">
                    <el-radio-group v-model="form.cardPoster">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="递名片">
                    <el-radio-group v-model="form.passCard">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="个性签名">
                    <el-radio-group v-model="form.personalitySignature">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="我的动态">
                    <el-radio-group v-model="form.dynamic">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="私信（IM）功能">
                    <el-radio-group v-model="form.IM">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="名片分享按钮">
                    <el-radio-group v-model="form.cardShare">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="保存名片">
                    <el-radio-group v-model="form.saveCard">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="CRM">
                    <el-radio-group v-model="form.CRM">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="名片模板">
                    <el-radio-group v-model="form.cardMould">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="人脉圈">
                    <el-radio-group v-model="form.networking">
                        <el-radio :label="0">关闭</el-radio>
                        <el-radio :label="1">开启</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-button type="primary" @click="submit">提交</el-button>
            </el-form>
        </el-card>
    </div>
</template>
<script>
    import {setCard,getCompanyInfo } from "@/api/buss"
    export default {
        data(){
            return {
                form:{
                    creattCard:1,
                    switchPosition:1,
                    authSwitch:1,
                    forceAuth:1,
                    replaceAvater:1,
                    cardPoster:1,
                    passCard:1,
                    personalitySignature:1,
                    dynamic:1,
                    IM:1,
                    cardShare:1,
                    saveCard:1,
                    CRM:1,
                    cardMould:1,
                    networking:1,
                }
            }
        },
        mounted(){
            getCompanyInfo().then(res=>{
                this.form.creattCard = res.data.set_up.is_card
                this.form.switchPosition = res.data.set_up.job_switch
                this.form.authSwitch = res.data.set_up.auth_switch
                this.form.forceAuth = res.data.set_up.force_switch
                this.form.replaceAvater = res.data.set_up.replace_switch
                this.form.passCard = res.data.set_up.exchange_switch
                this.form.personalitySignature = res.data.set_up.per_switch
                this.form.dynamic = res.data.set_up.dynamic_switch
                this.form.IM = res.data.set_up.chat_switch
                this.form.cardShare = parseInt(res.data.set_up.share_btn)

                this.form.cardPoster = res.data.set_up.poster_switch
                this.form.saveCard = res.data.set_up.save_switch
                this.form.CRM = res.data.set_up.crm_switch
                this.form.cardMould = res.data.set_up.moban_switch
                this.form.networking = res.data.set_up.rmq_switch

            })
        },
        methods:{
            submit(){
                setCard({
                    is_card :this.form.creattCard,
                    job_switch:this.form.switchPosition,
                    auth_switch:this.form.authSwitch,
                    force_switch:this.form.forceAuth,
                    replace_switch:this.form.replaceAvater,
                    exchange_switch:this.form.passCard,
                    per_switch:this.form.personalitySignature,
                    dynamic_switch:this.form.dynamic,
                    chat_switch:this.form.IM,
                    share_btn:this.form.cardShare,
                    poster_switch:this.form.cardPoster,
                    save_switch:this.form.saveCard,
                    crm_switch:this.form.CRM,
                    moban_switch:this.form.cardMould,
                    rmq_switch:this.form.networking
                }).then(res=>{
                    console.log(res)
                    this.$message.success(res.message)
                })
            }
        }
    }
</script>